﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;

namespace Redboil.Bfp.Client {
    public partial class App : Application {
        /// <summary>
        /// 未处理的异常
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) {
//            if(e.Exception == null) return;
//            string displayMessage = Infragistics.Samples.WPF.xamFeatureBrowser.Properties.Resources.GeneralExceptionPrompt + System.Environment.NewLine + System.Environment.NewLine;
//            while((e.Exception is System.Reflection.TargetInvocationException || e.Exception is System.Windows.Markup.XamlParseException) && e.Exception.InnerException != null)
//                e.Exception = e.Exception.InnerException;
//#if (DEBUG)
//            displayMessage += ex.ToString();
//#else
//            displayMessage += ex.Message;
//#endif
//            MessageBox.Show(displayMessage, Infragistics.Samples.WPF.xamFeatureBrowser.Properties.Resources.GeneralExceptionTitle, MessageBoxButton.OK, MessageBoxImage.Error);

            var result = MessageBox.Show("系统出现了不可处理的异常，请确认是否保存当前工作数据！", "保存数据", MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.Yes);
            if(result == MessageBoxResult.Yes) {
                //SaveDataWhenUnhandledException
            }
            e.Handled = true;
            Environment.Exit(-1);
            //Application.Current.Shutdown(0);
            //this.Shutdown(0);
        }
    }
}
